package cn.tedu.stock.webapi.service.Impl;

import cn.tedu.commons.pojo.stock.dto.StockReduceCountDTO;
import cn.tedu.stock.service.IStockService;
import cn.tedu.stock.webapi.mapper.StockMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
@DubboService
public class StockService implements IStockService {

    @Autowired
    private StockMapper stockMapper;

    @Override
    public void reduceCommodityCount(StockReduceCountDTO stockReduceCountDTO) {
        //第一个参数是商品编号，第二个参数是减少库存的数量
        stockMapper.updateStockCountByCommodityCode(stockReduceCountDTO.getCommodityCode(),stockReduceCountDTO.getReduceCount());
        log.info("商品库存减少完成！");
    }
}
